import itertools
from Primes import gen_primes
from Numbers import is_cuberoot
from Utils import len_gen

def f(n,p):
    return n*n*n + n*n*p

def findn(p):
    for n in xrange(1, 600):
        fn = f(n**3, p)
        if is_cuberoot(fn):
            return n
    return None


print len_gen(itertools.ifilter(lambda x: findn(x) is not None, itertools.takewhile(lambda x: x < 10**6, gen_primes())))
